cmake_minimum_required(VERSION 3.10.0)
project(pro CXX C CUDA)
add_definitions(-std=c++11 -w)
set(CUDA_NVCC_FLAGS "-gencode=arch=compute_86,code=sm_86;-G;-g;-O0;-w")

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/workspaces) # 设置工作目录

find_package(CUDA 11.1 REQUIRED)
find_package(OpenCV REQUIRED)
set(CUDA_DIR "/usr/local/cuda-11.1")

include_directories(
    ${PROJECT_SOURCE_DIR}/common
    ${OpenCV_INCLUDE_DIRS}
    ${CUDA_DIR}/include
)

link_directories(
    ${CUDA_DIR}/lib64
)

file(GLOB_RECURSE cuda_srcs
    ${PROJECT_SOURCE_DIR}/common/*.cu)
cuda_add_library(code_cu SHARED ${cuda_srcs})

add_executable(pro main.cpp)
target_link_libraries(pro
    code_cu
    cuda
    cublas
    cudart
    cudnn
    pthread
    ${OpenCV_LIBS}
)

add_custom_target(
    auto
    DEPENDS pro
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/workspaces
    COMMAND ./pro
)
